package anonymouschat.messages;

import java.io.Serializable;

/**
 * Only client end user receives the plain text message.
 * 
 * @author bh349
 * 
 */
public class TextMessage extends Message implements Serializable {
	private static final long serialVersionUID = 3013551852027023617L;
	private String srcUser;
	private String destinationUser; // User to which the message will be
									// delivered
	private String plaintextData; // Payload containing plaintext message
	private boolean goingUp;

	private Long incomingId = null;

	/**
	 * Construct a TextMessage
	 * 
	 * @param srcUser
	 * @param destinationUser
	 * @param plaintextData
	 * @param signature
	 * @param goingUp
	 */
	public TextMessage(String srcUser, String destinationUser,
			String plaintextData) {
		super();
		this.srcUser = srcUser;
		this.destinationUser = destinationUser;
		this.plaintextData = plaintextData;
		this.goingUp = true;
	}

	public String getSrcUser() {
		return srcUser;
	}

	public String getDstUser() {
		return destinationUser;
	}

	public String getPlaintextData() {
		return plaintextData;
	}

	public void setDownId(Long downId) {
		incomingId = downId;
	}

	
	public Long getIncomingId() {
		return incomingId;
	}

	/**
	 * sets isgoingUp to true, meaning it's going upstream to a publication server
	 * @return
	 */
	public boolean isGoingUpstream() {
		return goingUp;
	}

	/**
	 * Sets isGoingUp to false, meaning it's going downstream to a client
	 */
	public void setGoingUpFalse() {
		goingUp = false;
	}

	@Override
	public String getAllContents() {
		return "TextMessage: " + "\n\tsrc: " + srcUser + "\n\tdest:"
				+ destinationUser + "\n\tdata:" + plaintextData;
	}

}
